package  
{
	import flash.display.Shape;
	import flash.events.Event;
	/**
	 * ...
	 * @author hbb
	 */
	public class Process 
	{
		
		private var _tickedObjs:Array = [];
		
		private var _driver:Shape = new Shape();
		
		
		public function addTickedObj( ob:ITickedObject ):void
		{
			if ( _tickedObjs.indexOf( ob ) == -1 )
				_tickedObjs.push( ob );
		}
		
		public function removeTickedObj( ob:ITickedObject ):void
		{
			var i:int = _tickedObjs.indexOf( ob );
			if ( i != -1 )	_tickedObjs.splice( i, 1 );
		}
		
		public function start():void
		{
			_driver.addEventListener(Event.ENTER_FRAME, loop);
		}
		
		public function stop():void
		{
			_driver.removeEventListener(Event.ENTER_FRAME, loop);
		}
		
		private function loop(e:Event):void 
		{
			for ( var i:int = 0; i < _tickedObjs.length; ++i )
			{
				_tickedObjs[ i ].onTick();
			}
		}
		
	}

}